﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjectEuler
{
    //http://projecteuler.net/problem=1
    //If we list all the natural numbers below 10 that are multiples of 3 or 5, 
    //we get 3, 5, 6 and 9. The sum of these multiples is 23.
    //Find the sum of all the multiples of 3 or 5 below 1000.
   public class p1:Problem
    {
        public override string Solution(params long[] param)
        {
            Int64 N=param==null?1000:param[0];
            N--;//BELOW the given number
            //three arithmetic progreessions
            Int64 res = N / 3 * (3 + N/3*3)/2                //multiples of 3
                       + N / 5 * (5 + N / 5 * 5) / 2         //multiples of 5
                       - N / 15 * (15 + N / 15 * 15) / 2;    //multiples of 15 - because both of the above count them
          
            return res.ToString() ;
        }
        public override string strParamPrompt
        {
            get { return "Enter upper limit(1000):";}
        }
    }

}
